package com.yhao.simpledemo.util;

import java.util.UUID;

/**
 * @author : yhao
 * @Date : 2024/1/18 - 20:29
 * @Desc : TODO
 */
public class MyThread extends Thread {

    static int ticket = 0;//静态修饰

    String threadName = "";

    public MyThread(String threadName) {
        this.threadName = threadName;
    }

    @Override
    public void run() {
        while (ticket++ < 20) {
            String currentName = UUID.randomUUID().toString();
            try {
                //休眠1秒
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("currentName=[" + currentName + "]    " + Thread.currentThread().getName() + "窗口正在卖第" + ticket + "张票");
        }
    }

}
